package com.isoft.c2team3service2.controller;

import com.isoft.c2team3service2.common.Result;
import com.isoft.c2team3service2.entity.PrivatePost;
import com.isoft.c2team3service2.entity.UserDTO;
import com.isoft.c2team3service2.service.PrivatePostService;
import com.isoft.c2team3service2.util.UserHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/private-post")
public class PrivatePostController {

    @Autowired
    private PrivatePostService privatePostService;

    // 向艺人发送私密帖子
    @PostMapping("/send/{artistId}")
    public Result<?> sendPrivatePost(@PathVariable Integer artistId, @RequestParam String content) {
        boolean b = privatePostService.sendPrivatePost(artistId, content);
        if (b) {
            return Result.success("发送成功");
        }
        return Result.error("更新失败或涉及敏感字眼");
    }

    // 获取与特定艺人的私密对话
    @GetMapping("/conversation/{artistId}")
    public List<PrivatePost> getPrivateConversation(@PathVariable Integer artistId) {
        return privatePostService.getPrivateConversation(artistId);
    }

    // 获取用户的所有私密帖子
    @GetMapping("/my-posts")
    public List<PrivatePost> getMyPrivatePosts() {
        return privatePostService.getPrivatePosts(null);
    }
}